﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MockPrjTeam1.Entity;
using MockPrjTeam1.Biz;

namespace MockPrjTeam1.Pages.Views
{
    public partial class SearchAddress : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var biz = new SearchBiz();
                var result = biz.Load();
                GrVSearchAddress.DataSource = result;
                GrVSearchAddress.DataBind();
            }
        }
    
        protected void GrvSearchAddress_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            var biz = new SearchBiz();
            var result = biz.Load();
            GrVSearchAddress.PageIndex = e.NewPageIndex;
            GrVSearchAddress.DataSource = result;
            GrVSearchAddress.DataBind();
            
        }

        
        protected void btnClear_Click(object sender, EventArgs e)
        {
            txtPostCode.Text = "";
            txtStreet.Text = "";
            txtTown.Text = "";
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            var PostCode = Convert.ToString(txtPostCode.Text);
            var Street = Convert.ToString(txtStreet.Text);
            var Town = Convert.ToString(txtTown.Text);
            
            var Searchbiz = new SearchBiz();
            var result = Searchbiz.Search(PostCode, Street, Town);
            GrVSearchAddress.DataSource = result;
            GrVSearchAddress.DataBind();
           
        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            Response.Redirect("../Forms/AddressDetail.aspx");
        }

       
    }
}